#define  _CRT_SECURE_NO_WARNINGS
#include <string>
using namespace std;

class Solution {
public:
    int lengthOfLastWord(string s) {
        int ret = 0;
        int i = s.size() - 1;
        while (i >= 0)
        {
            if (s[i] == ' ') i--;
            else
            {
                while (i >= 0 && isalpha(s[i--])) ret++;
                break;
            }
        }
        return ret;
    }
};